package com.shumei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shumei.dao.mapper.ApplicationMapper;
import com.shumei.dao.pojo.Application;
import com.shumei.service.ApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ApplicationServiceImpl implements ApplicationService {
    @Autowired
    ApplicationMapper applicationMapper;
    @Override
    public List<Application> selectApplication() {
        List<Application> applications=applicationMapper.selectList(null);

        return applications;
    }

    @Override
    public void insertApplication(Application application) {
        int i = applicationMapper.insert(application);
        if (i > 0) {
            System.out.println("应聘表插入成功");

        } else {
            System.out.println("应聘表插入失败");

        }
    }

    @Override
        public void updateApplication(Application application) {
        QueryWrapper<Application> wrapper=new QueryWrapper<Application>();
        wrapper.eq("id",application.getId());

        if (applicationMapper.update(application,wrapper)>0){
            System.out.println("修改成功");
        }
        else {
            System.out.println("修改失败");
        }
    }

    @Override
    public void deleteApplication(int id) {
        int i = applicationMapper.deleteById(id);
        if (i>0) {
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }
}
